package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.TmcTopBanner;
import com.ruoyi.system.mapper.BannerMapper;
import com.ruoyi.system.service.BannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Calendar;
import java.util.List;

@Service
public class BannerServiceImpl implements BannerService {
    @Autowired
    private BannerMapper bannerMapper;

    @Override
    public List<TmcTopBanner> queryBannerList(TmcTopBanner tmcTopBanner) {
        return bannerMapper.queryBannerList(tmcTopBanner);
    }

    @Override
    public TmcTopBanner queryBannerById(Long id) {
        return bannerMapper.queryBannerById(id);
    }

    @Override
    public List<TmcTopBanner> queryBanner() {
        return bannerMapper.queryBanner();
    }
    /**
     * 新增轮播图
     *
     * @param tmcTopBanner 轮播图
     * @return 结果
     */
    @Override
    public int insertTmcTopBanner(TmcTopBanner tmcTopBanner)
    {
        //获取当前时间
        Calendar calendar = Calendar.getInstance();
        tmcTopBanner.setCreatetime(calendar.getTime());
        int i = bannerMapper.insertTmcTopBanner(tmcTopBanner);
        return tmcTopBanner.getId().intValue();
    }

    /**
     * 修改轮播图
     *
     * @param tmcTopBanner 轮播图
     * @return 结果
     */
    @Override
    public int updateTmcTopBanner(TmcTopBanner tmcTopBanner)
    {
        return bannerMapper.updateTmcTopBanner(tmcTopBanner);
    }

    /**
     * 批量删除轮播图
     *
     * @param ids 需要删除的轮播图ID
     * @return 结果
     */
    @Override
    public int deleteTmcTopBannerByIds(Long[] ids)
    {
        return bannerMapper.deleteTmcTopBannerByIds(ids);
    }

    /**
     * 删除轮播图信息
     *
     * @param id 轮播图ID
     * @return 结果
     */
    @Override
    public int deleteTmcTopBannerById(Long id)
    {
        return bannerMapper.deleteTmcTopBannerById(id);
    }
}
